<ul>
  {% for category in categories %}
    <li>
      {% if category.slug == active or category.slug|add:'_all' == active %}
        <ul class="category-active">
          <li><a href="{% url gallery_category category.slug %}" class="active">{{ category.name }}</a></li>
          <li>
            {% if category.slug == active %}
              <a href="{% url gallery_category_all category.slug %}">Overview</a>
            {% else %}
              <a href="{% url gallery_category category.slug %}">List</a>
            {% endif %}
          </li>
        </ul>
      {% else %}
       <a href="{% url gallery_category category.slug %}">{{ category.name }}</a>
      {% endif %}
    </li>
  {% endfor %}
</ul>